package com.ruoyi.web.controller.crm;

import com.bonuo.crm.domain.CustomerVisit;
import com.bonuo.crm.service.CustomerVisitService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/crm/customerVisit")
@RestController
@Api(tags = "客户来访管理")
public class CustomerVisitController extends BaseController {

    @Autowired
    private CustomerVisitService customerVisitService;

    @ApiOperation(value = "客户来访列表",httpMethod = "GET")
    @GetMapping("/list")
    public TableDataInfo list(CustomerVisit customerVisit) {
        startPage();
        List<CustomerVisit> customerVisitList = customerVisitService.selectCustomerVisitList(customerVisit);
        return getDataTable(customerVisitList);
    }

    @ApiOperation(value = "客户来访添加",httpMethod = "POST")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody CustomerVisit customerVisit) {
        return toAjax(customerVisitService.insertCustomerVisit(customerVisit));
    }

    @ApiOperation(value = "客户来访修改",httpMethod = "PUT")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody CustomerVisit customerVisit) {
        return toAjax(customerVisitService.updateCustomerVisit(customerVisit));
    }

    @ApiOperation(value = "客户来访删除",httpMethod = "DELETE")
    @DeleteMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable Integer id) {
        return toAjax(customerVisitService.deleteCustomerVisitById(id));
    }

}
